#include<iostream>
using namespace std;
int main()
{
	int a[] = { 6,7,8,9,5,4,8,7,9 };
	int n = 9;
	int max = a[0];
	int min=a[0];
	int b;
	int c;
	for (int i = 0;i < n;i++)
	{
		cout <<" "<< a[i];
		if (min > a[i]) {
			min = a[i];
			b = i;
		}
		if (max < a[i]) {
			max = a[i];
			c = i;
		}
	}
	for (int i = b ;i < n;i++)
	{	
			a[i] = a[i + 1];
	}
	n--;
	for (int i = c;i < n;i++)
	{
			a[i] = a[i + 1];
	}
	n--;
	cout << endl;
	for (int i = 0;i < n;i++)
	{
		cout <<" "<< a[i];
	}
    return 0;
}
